<template>
  <div class="traybox">
    <div class="musicbox">
      <div class="info">
        <div class="imgbox">
          <!-- <img src="../../../static/images/user.jpg" alt="" /> -->
          <img :src="getImgUrl" alt />
        </div>
        <div class="name_author">
          <span class="name">{{ getName }}</span>
          <span class="author">{{ getAuthor }}</span>
          <!-- <span class="name">如何</span> -->
          <!-- <span class="author">添呗儿</span> -->
        </div>
      </div>
      <div class="control">
        <div>
          <i @click="prevSong" class="iconfont icon-shangyishou"></i>
        </div>
        <div class="play_pause" @click="play_pause">
          <i v-if="!getState" class="iconfont icon-bofang"></i>
          <i v-else class="iconfont icon-tingzhi"></i>
        </div>
        <div>
          <i @click="nextSong" class="iconfont icon-xiayishou"></i>
        </div>
      </div>
    </div>
    <div class="btnbox">
      <ul>
        <li @click="showMain">
          <i class="iconfont icon-diannao"></i>
          <span>显示主界面</span>
        </li>
        <li>
          <i class="iconfont icon-shezhi2"></i>
          <span>设置</span>
        </li>
        <li>
          <i class="iconfont icon-ci-copy"></i>
          <span>音乐歌词</span>
        </li>
        <li @click="winClose">
          <i class="iconfont icon-close"></i>
          <span>退出音乐</span>
        </li>
      </ul>
    </div>
  </div>
</template>
<script>
import { mapGetters } from "vuex"
export default {
  data() {
    return {
      // getState: false,
      volume: 30,
    }
  },
  computed: {
    ...mapGetters([
      "getName",
      "getAuthor",
      "getMusicUrl",
      "getImgUrl",
      "getModel",
      "getMusicList",
      "getState",
      "getLyrics",
    ]),
  },
  methods: {
    // 上一首
    prevSong() {
      this.$store.dispatch("prev")
    },

    // 下一首
    nextSong() {
      this.$store.dispatch("next")
    },

    // 播放__暂停
    play_pause() {
      this.$store.dispatch("playOrPause")
    },
    // 显示主界面
    showMain() {
      this.$electron.ipcRenderer.send("showWindow")
    },

    winClose() {
      this.$electron.ipcRenderer.send("winClose") // 关闭主界面
      this.$electron.ipcRenderer.send("closeTray") //关闭系统托盘
    },
  },
}
</script>
<style lang="scss" scoped>
.info {
  display: flex;
  height: 70px;
  width: 100%;
  .imgbox {
    height: 70px;
    width: 70px;
    display: flex;
    justify-content: center;
    align-items: center;
    img {
      width: 50px;
      height: 50px;
      border-radius: 5px;
    }
  }
  .name_author {
    width: calc(100% - 70px);
    height: 100%;
    padding: 10px 0px;
    box-sizing: border-box;
    span {
      display: inline-block;
      width: 100%;
      height: 25px;
      line-height: 25px;
    }
    .name {
      font-size: 14px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .author {
      font-size: 12px;
      color: rgb(143, 140, 140);
    }
  }
}
.control {
  display: flex;
  height: 70px;
  width: 100%;
  div {
    flex: 1;
    width: 60px;
    height: 70px;
    display: flex;
    justify-content: center;
    align-items: center;
    i {
      font-size: 32px;
    }
  }
  .play_pause {
    width: 60px;
    text-align: center;
    justify-content: center;
    align-items: center;
    i {
      font-size: 50px;
    }
  }
  div:hover {
    cursor: pointer;
  }
}
.btnbox {
  ul {
    li {
      display: flex;
      height: 40px;
      display: flex;
      justify-content: center;
      align-items: center;
      i {
        flex: 3;
        display: flex;
        justify-content: center;
        align-items: center;
      }
      .icon-ci-copy {
        font-size: 19px;
      }
      .icon-shezhi2 {
        font-size: 18px;
      }
      span {
        flex: 7;
        display: flex;
        justify-content: start;
        align-items: center;
      }
    }
    li:last-child {
      border-top: 1px solid #ccc;
    }
    li:hover {
      cursor: pointer;
    }
  }
}
</style>
